package com.xm.task;

import com.xm.pojo.Bilibili;
import com.xm.service.JobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;

@Component
public class SpringDataPipeline implements Pipeline {
    @Autowired
    private JobService JobService;

    @Override
    public void process(ResultItems resultItems, Task task) {
        Bilibili bilibili = (Bilibili)resultItems.get("bilibili");

        if (bilibili!=null){
            System.out.println("开始保存-----");
            this.JobService.save(bilibili);
        }
    }
}
